package edu.gatech.coc.betameisters.userinterfaces;

import javax.swing.JPanel;
import javax.swing.JLabel;
import javax.swing.JButton;

import edu.gatech.coc.betameisters.main.MainPanel;
import edu.gatech.coc.betameisters.people.Person;
import edu.gatech.coc.betameisters.people.SystemAdmin;

import javax.swing.JComboBox;
import javax.swing.DefaultComboBoxModel;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;

public class EditUser extends JPanel {

	/**
	 * 
	 */
	private boolean nonPersonFlag = false;
	/**
	 * 
	 */
	private static final long serialVersionUID = 2824547895976821437L;
	@SuppressWarnings("unused")
	private MainPanel myParent;

	/**
	 * Create the panel.
	 */
	public EditUser(Person thisPerson, MainPanel p) {
		if(thisPerson == null){
			nonPersonFlag = true;
		}
		setLayout(null);
		myParent = p;
		JLabel lblEditUserDetails = new JLabel("Edit User Details");
		lblEditUserDetails.setBounds(175, 11, 84, 14);
		add(lblEditUserDetails);
		
		JButton btnResetUsersPassword = new JButton("Reset User's Password");
		btnResetUsersPassword.setBounds(270, 115, 170, 23);
		add(btnResetUsersPassword);
		
		JButton btnSuspendUsersAccount = new JButton("Suspend User's Account");
		btnSuspendUsersAccount.setBounds(270, 81, 170, 23);
		add(btnSuspendUsersAccount);
		
		JButton btnUnsuspendUsersAccount = new JButton("Unsuspend User's Account");
		btnUnsuspendUsersAccount.setBounds(270, 47, 170, 23);
		add(btnUnsuspendUsersAccount);
		
		JLabel lblFirstName = new JLabel("First Name:");
		lblFirstName.setBounds(10, 47, 68, 14);
		add(lblFirstName);
		
		JLabel lblLastName = new JLabel("Last Name:");
		lblLastName.setBounds(10, 90, 68, 14);
		add(lblLastName);
		
		JLabel lblUsername = new JLabel("Username:");
		lblUsername.setBounds(10, 133, 68, 14);
		add(lblUsername);
		
		JLabel lblUserType = new JLabel("User Type:");
		lblUserType.setBounds(10, 179, 68, 14);
		add(lblUserType);
		
		JButton btnSubmitChanges = new JButton("Change Account Type");
		btnSubmitChanges.setEnabled(false);
		btnSubmitChanges.setBounds(275, 175, 165, 23);
		add(btnSubmitChanges);
		
		JButton btnCancel = new JButton("Back");
		btnCancel.addMouseListener(new MouseAdapter() {
			@Override
			public void mouseClicked(MouseEvent arg0) {
				myParent.setMyAdmin((SystemAdmin) myParent.getUser());
			}
		});
		btnCancel.setBounds(10, 266, 89, 23);
		add(btnCancel);
		
		String attribute = "";
		if(!nonPersonFlag){
			attribute = thisPerson.getFirstName();
		}
		JLabel lblUserFirstName = new JLabel(attribute);
		lblUserFirstName.setBounds(71, 47, 89, 14);
		add(lblUserFirstName);
		
		if(!nonPersonFlag){
			attribute = thisPerson.getLastName();
		}
		JLabel lblUserLastName = new JLabel(attribute);
		lblUserLastName.setBounds(73, 90, 87, 14);
		add(lblUserLastName);
		
		if(!nonPersonFlag){
			attribute = thisPerson.getUserID();
		}
		JLabel lblUserUsername = new JLabel(attribute);
		lblUserUsername.setBounds(71, 133, 89, 14);
		add(lblUserUsername);
		
		JComboBox comboBoxUserType = new JComboBox();
		comboBoxUserType.setModel(new DefaultComboBoxModel(new String[] {"PATIENT", "NURSE", "DOCTOR", "ADMIN"}));
		comboBoxUserType.setBounds(71, 176, 89, 20);
		add(comboBoxUserType);

	}

}
